/**
 @file ctc_npm.h

 @date 2016-4-20

 @version v1.0

*/

#ifndef _CTC_NPM_H
#define _CTC_NPM_H
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "ctc_const.h"
#include "ctc_stats.h"
/****************************************************************
*
* Defines and Macros
*
****************************************************************/
#define CTC_NPM_MAX_EMIX_NUM 16

#define CTC_NPM_LITE_SESSION_NUM            512
#define CTC_NPM_EVENT_MAX_NUM               8

#define CTC_NPM_SESSION_TYPE_LITE   1
#define CTC_NPM_SESSION_ID_LEN 28
#define CTC_NPM_IS_LITE_SESSION(session_id)      ((session_id>>CTC_NPM_SESSION_ID_LEN) == CTC_NPM_SESSION_TYPE_LITE)

/*
 @brief   Define npm cfg flags
*/
enum ctc_npm_cfg_flag_e
{
    CTC_NPM_CFG_FLAG_TS_EN             = 1U << 0,  /**< [D2.TM.TMM.AT] Enable insert transmit timestamp, for delay measurement */
    CTC_NPM_CFG_FLAG_SEQ_EN            = 1U << 1,  /**< [D2.TM.TMM.AT] Enable insert sequence number */
    CTC_NPM_CFG_FLAG_ILOOP             = 1U << 2,  /**< [D2.TM.TMM.AT] Indicate key for up MEP */
    CTC_NPM_CFG_FLAG_BURST_EN          = 1U << 3,  /**< [D2.TM.TMM.AT] Enable generator traffic in burst mode */
    CTC_NPM_CFG_FLAG_MCAST             = 1U << 4,  /**< [D2.TM.TMM.AT] Indicate Destination global port is mcast dest-group-id */
    CTC_NPM_CFG_FLAG_DMR_NOT_TO_CPU    = 1U << 5,  /**< [D2.TM.TMM.AT] Indicate session use DMM/DMR for NPM test, DMR not to CPU*/
    CTC_NPM_CFG_FLAG_RX_ROLE_EN        = 1U << 6,  /**< [D2.TM.TMM.AT] Only enable rx role */
    CTC_NPM_CFG_FLAG_NTP_TS            = 1U << 7,  /**< [TM.TMM.AT] If set, indicate timestamp use NTP, else PTPv2*/
    CTC_NPM_CFG_COLOR                  = 1U << 8,  /**< [D2.TM.TMM.AT] Color is set*/
    CTC_NPM_CFG_PRIORITY               = 1U << 9,  /**< [D2.TM.TMM.AT] Priority is set*/
    CTC_NPM_CFG_FLAG_TWAMP_LITE        = 1U << 10,  /**< [TMM.AT] If set, indicate use the lite mode for TWAMP*/
    CTC_NPM_CFG_FLAG_DMM_LITE          = 1U << 11, /**< [TMM.AT] If set, indicate use the lite mode for DMM*/
    CTC_NPM_CFG_FLAG_FLR_FOR_SES       = 1U << 12, /**< [TMM.AT]  Set the ratio of lost frames  for SES*/
    CTC_NPM_CFG_FLAG_AVL_PERIOD_THRD   = 1U << 13, /**< [TMM.AT]Set the seconds count to go into(out of) available period*/
    CTC_NPM_CFG_FLAG_NHID_VALID        = 1U << 14, /**< [D2.TM.TMM.AT] Indicate Use nhid to forward*/
    CTC_NPM_CFG_FLAG_VRF_EN            = 1U << 15, /**< [TMM.AT] If Set, indicate twamp re-route with vrf*/
    CTC_NPM_CFG_FLAG_OFFSET_ADJ        = 1U << 16, /**< [TMM.AT] If Set, indicate twamp packet offset adjust enable only use for l3vpn after acl offset*/
    CTC_NPM_CFG_FLAG_TUNNEL_PKT      = 1U << 17, /**< [AT] If Set, indicate insert transmit timestamp in inner packet*/
    CTC_NPM_CFG_FLAG_MAX
};
typedef enum ctc_npm_cfg_flag_e ctc_npm_cfg_flag_t;

/**
 @brief  Define npm packet format
 Note1: Support below packet type
   |   Packet Type    |                       Descroption                |                                   Remark                                |
   |------------------|--------------------------------------------------|-------------------------------------------------------------------------|
   |    DMM/DMR       |ITU.T Y.1731, Frame Delay metrics                 |Test based on MEP, config MEP to identify test pkt and send to OAM engine|
   |    SLM/SLR       |Based on Y.1731, Frame Delay and Loss metrics     |Test based on MEP, config MEP to identify test pkt and send to OAM engine|
   |    LBM/LBR       |Based on Y.1731, Frame Loss metrics               |Test based on MEP, config MEP to identify test pkt and send to OAM engine|
   |    ETH TST       |Based on Y.1731, Frame Loss metrics               |Test based on MEP, config MEP to identify test pkt and send to OAM engine|
   |    OWAMP         |RFC4656 , One-Way Frame Delay and Loss metrics    |must use ACL to identify as CTC_ACL_OAM_TYPE_FLEX, and send to NPM engine|
   |    TWAMP         |RFC5357 , Two-Way Frame Delay and Loss metrics    |must use ACL to identify as CTC_ACL_OAM_TYPE_FLEX, and send to NPM engine|
   |    TWAMP-LITE    |RFC5357 , Two-Way Frame Delay and Loss metrics    |must use ACL to identify as CTC_ACL_OAM_TYPE_FLEX, and send to NPM engine|
   |    DMM-LITE      |ITU.T Y.1731, Frame Delay metrics                 |Test based on MEP, config MEP to identify test pkt and send to OAM engine|
   |    UDP-ECHO      |Frame Delay and Loss metrics                      |must use ACL to identify as CTC_ACL_OAM_TYPE_FLEX, and send to NPM engine|
   |    FL-PDU        |MEF 49, One-Way Frame Loss metrics                |must use ACL to identify as CTC_ACL_OAM_TYPE_FLEX, and send to NPM engine|
   |    FLEX          |User defined packet type, Frame Loss metrics      |must use ACL to identify as CTC_ACL_OAM_TYPE_FLEX, and send to NPM engine|
 Note2: When Tx NPM test PDUs, encape different NPM test PDUs to ctc_npm_pkt_format_t.pkt_header,(DMM/DMR,SLM/SLR,OWAMP..)
        use ctc_npm_cfg_t to set features of test PDU. For example, ts_offset and seq_num_offset are
        used to add timestamp and seq num in test PDU.(such as OWAMP/TWAMP, seq_num_offset=42 ts_offset=46)
 Note3: When Rx NPM test PDUs and using OWAMP/TWAMP/UDP Echo/FL-PDU/FLEX to do KPI metrics.
        If doing two-way test such as TWAMP/UDP Echo, receiever device just reflect receieved PDUs to sender device.
        If doing one-way test such as OWAMP/FLEX, reveiver device need set CTC_NPM_CFG_FLAG_RX_ROLE_EN and config ts_offset/seq_num_offset
        to get timestamp and seq num from receieved PDUs.
 Note4: When using FL-PDU and FD-PDU to do KPI metrics, need creat two test sessions at the same time (refer to MEF 49)
 Note5: Detail config please refer to <<SDKTypicalConfiguration_APP>>
 Note6:  Bit28~bit31 of session id means the session type, "0000" is normal mode session and "0001" is LITE mode session.
 */

 /***************************Session id construct***********************************
 *   |-----Type---- |------------Resv------------ |----------Session id---------|  *
 *   |    31-28     |            27-9             |            8 - 0            |  *
 *   |--------------|-----------------------------|---------------------------- |  *
 **********************************************************************************/

struct ctc_npm_pkt_format_s
{
    void*  pkt_header;                     /**< [D2.TM.TMM.AT] User-defined data, used to encape NPM Test PDU, Max size refer to ctc_npm_session_mode_t */
    uint16 header_len;                     /**< [D2.TM.TMM.AT] User-defined data length, not include crc */
    uint8  pattern_type;                   /**< [D2.TM.TMM.AT] Payload pattern type, refer to ctc_npm_pattern_type_t */
    uint8  ipg;                            /**< [D2.TM.TMM.AT] Inter-packet gap, should be same as mac config */

    uint16 seq_num_offset;                 /**< [D2.TM.TMM.AT] Offset sequence number in user-defined packet when CTC_NPM_CFG_FLAG_SEQ_EN flag is set*/
    uint16 ts_offset;                      /**< [D2.TM.TMM.AT] Offset in bytes of timestamp when CTC_NPM_CFG_FLAG_TS_EN flag is set */
    uint32 repeat_pattern;                 /**< [D2.TM.TMM.AT] Used for repeat payload type */

    uint8  frame_size_mode;                /**< [D2.TM.TMM.AT] Packet size mode, 0: Fixed, 1: Increased, 2:Emix*/
    uint8  emix_size_num;                  /**< [D2.TM.TMM.AT] Used when size_mode is emix, means emix size num*/
    uint16 emix_size[CTC_NPM_MAX_EMIX_NUM];/**< [D2.TM.TMM.AT] emix size, emix size refer to global cfg for emix size*/
    uint32 frame_size;                     /**< [D2.TM.TMM.AT] Total packet size, include header_len and crc, must >= 64 && >= header_len + 4 bytes,
                                           when size_mode is fixed, means packet size; when size_mode is Increased, means max packet size*/
    uint32 min_frame_size;                 /**< [D2.TM.TMM.AT] Min packet size when size_mode is Increased */
    uint8   priority;                      /**< [D2.TM.TMM.AT] Priority of the packet,range is [0, 15]  */
    uint8   color;                         /**< [D2.TM.TMM.AT] Color of the packet, refer to ctc_qos_color_t */
    uint16  chksum_offset;                /**< [TM.TMM.AT] Offset for update checksum, 0 means disable update checksum */
};
typedef struct ctc_npm_pkt_format_s ctc_npm_pkt_format_t;

enum ctc_npm_measure_mode_e
{
    CTC_NPM_MEASURE_MODE_TWO_WAY = 0,  /**< [TMM.AT] Two-way delay/jitter measure */
    CTC_NPM_MEASURE_MODE_FAR_END,      /**< [TMM.AT] Far end delay/jitter measure */
    CTC_NPM_MEASURE_MODE_NEAR_END,     /**< [TMM.AT] Near end delay/jitter measure */
    CTC_NPM_MAX_MEASURE_MODE
};
typedef enum ctc_npm_measure_mode_e ctc_npm_measure_mode_t;

enum ctc_npm_session_lite_mode_e
{
    CTC_NPM_SESSION_LITE_MODE_SENDER = 0,          /**< [TMM.AT] Session is sender mode */
    CTC_NPM_SESSION_LITE_MODE_REFLECTOR_FULL,      /**< [TMM.AT] Session is reflector full mode */
    CTC_NPM_SESSION_LITE_MODE_REFLECTOR_LIGHT,     /**< [TMM.AT] Session is reflector light mode */
    CTC_NPM_SESSION_LITE_MODE_MAX
};
typedef enum ctc_npm_session_lite_mode_e ctc_npm_session_lite_mode_t;


struct ctc_npm_lite_cfg_s
{
    uint8 enable;               /**< [TMM.AT] TWAMP/DMM lite mode enable */

    uint8 mode;                 /**< [TMM.AT] 0: Session-sender, 1: Session-reflector full mode, 2: Session-reflector light mode, refer to ctc_npm_session_lite_mode_t */
    uint16 dst_port;            /**< [TMM.AT] Only valid for TWAMP,  UDP destport */
    uint16 src_port;            /**< [TMM.AT] Only valid for TWAMP,  UDP sourceport */
    uint32 nhid;                /**< [TMM.AT] NextHop id */
    uint8 is_ipv6;              /**< [TMM.AT] If set, indicate twamp packet with ipv6 address */
    ip_addr_t   ip4_sa;         /**< [TMM.AT] IPv4 source address */
    ip_addr_t   ip4_da;         /**< [TMM.AT] IPv4 destination address */
    ipv6_addr_t ipv6_sa;        /**< [TMM.AT] IPv6 source address */
    ipv6_addr_t ipv6_da;        /**< [TMM.AT] IPv6 destination address */
    uint32 lmep_index;          /**< [TMM.AT] [In/Out] Local mep index. When "mep_index_alloc_by_sdk" is enable in OAM, means lmep_index is
                                allocated by SDK which is a output value, otherwise means is allocated by system which is a input value*/

    uint8 dm_tx_type;           /**< [TMM.AT] DM format, 0: DMM, 1: 1DM */
	uint8 tx_cos_exp;          /**< [TMM.AT] Tx cos value*/
};
typedef struct ctc_npm_lite_cfg_s ctc_npm_lite_cfg_t;


/**
 @brief  Define npm cfg parameter, determine features of NPM test PDUs.
*/
struct ctc_npm_cfg_s
{
    uint32 flag;                            /**< [D2.TM.TMM.AT] refer to ctc_npm_cfg_flag_t */
    uint32 session_id;                      /**< [D2.TM.TMM.AT] NPM session id */
    uint8 tx_mode;                          /**< [D2.TM.TMM.AT] Tx mode, refer to ctc_npm_tx_mode_t */
    uint8 timeout;                          /**< [D2.TM.TMM.AT] Enable timeout for On-demand test, 0 means disable, unit:s */
    uint8 rx_role_en;                       /**< [D2.TM.TMM.AT] If set, indicate rx roler enable, when CTC_NPM_CFG_FLAG_RX_ROLE_EN flag is set */

    uint32 rate;                            /**< [D2.TM.TMM.AT] For TWAMP and DMM LITE ,it means packet tx interval, 
                                                  TWAMP LITE accuracy is 1ms, DMM LITE is 1/4 of MEP CCM interval;
                                                  For other packet, indicate generate traffic speed(Kbps) */
    uint32 tx_period;                       /**< [D2.TM.TMM.AT] Used for generate pkts when in tx CTC_NPM_TX_MODE_PERIOD mode, unit: 1s */
    uint32 packet_num;                      /**< [D2.TM.TMM.AT] Used for generate pkts when in tx CTC_NPM_TX_MODE_PACKET mode, and it's also useful for lite mode from AT*/

    uint32 burst_cnt;                       /**< [D2.TM.TMM.AT] burst cnt when burst enable*/
    uint32 ibg;                             /**< [D2.TM.TMM.AT] Inter-Burst Gap, used for burst packet, uint:us, 0: using default*/

    uint32 nh_id;                           /**< [D2.TM.TMM.AT] nexthop id */
    uint32 dest_gport;                      /**< [D2.TM.TMM.AT] Destination global port ID or mcast group id */
    uint16 vlan_id;                         /**< [D2.TM.TMM.AT] Vlan id */
    uint16 vrf_id;                          /**< [TMM.AT] vrf id */
    uint8  vlan_domain;                     /**< [D2.TM.TMM.AT] Vlan domain, when set 1, indicate cvlan-doamin,else svlan-domain */
    uint8  dm_stats_mode;                   /**< [TM.TMM.AT] refer to ctc_npm_measure_mode_t */
    uint8  oam_type;                        /**< [TM.TMM.AT] OAM type, refer to ctc_oam_type_t */
    ctc_npm_pkt_format_t pkt_format;        /**< [D2.TM.TMM.AT] npm packet format */
    ctc_npm_lite_cfg_t lite_cfg;            /**< [TMM.AT] TWAMP lite mode config */
    uint8 flr_for_ses;                      /**< [TMM.AT] The rate threshold to judge if is ses or not, when CTC_NPM_CFG_FLAG_FLR_FOR_SES flag is set */
    uint32 avl_period_thrd;                 /**< [TMM.AT]  The seconds count to go into(out of) available period when CTC_NPM_CFG_FLAG_AVL_PERIOD_THRD flag is set */
};
typedef struct ctc_npm_cfg_s ctc_npm_cfg_t;


enum ctc_npm_tx_mode_e
{
    CTC_NPM_TX_MODE_CONTINUOUS = 0,  /**< [D2.TM.TMM.AT] Transmit continuously */
    CTC_NPM_TX_MODE_PACKET_NUM,      /**< [D2.TM.TMM.AT] Stop packets transmission after the number of packet transmission */
    CTC_NPM_TX_MODE_PERIOD,          /**< [D2.TM.TMM.AT] Stop packets transmission after a period of packet transmission */

    CTC_NPM_TX_MODE_MAX
};
typedef enum ctc_npm_tx_mode_e ctc_npm_tx_mode_t;



/*
 @brief   Define NPM generator pattern type
*/
enum ctc_npm_pattern_type_e
{
    CTC_NPM_PATTERN_TYPE_REPEAT,       /**< [D2.TM.TMM.AT] Repeat mode */
    CTC_NPM_PATTERN_TYPE_PRBS,         /**< [D2.TM.TMM.AT] Random mode */
    CTC_NPM_PATTERN_TYPE_INC_BYTE,     /**< [D2.TM.TMM.AT] Increase by byte mode */
    CTC_NPM_PATTERN_TYPE_DEC_BYTE,     /**< [D2.TM.TMM.AT] Decrease by byte mode */
    CTC_NPM_PATTERN_TYPE_INC_WORD,     /**< [D2.TM.TMM.AT] Increase by word mode */
    CTC_NPM_PATTERN_TYPE_DEC_WORD,     /**< [D2.TM.TMM.AT] Decrease by word mode */

    CTC_NPM_PATTERN_TYPE_MAX
};
typedef enum ctc_npm_pattern_type_e ctc_npm_pattern_type_t;

/*
 @brief   Define NPM stats structure, used to calculate KPI metrics
 Note1: When get autogen stats, if session transmit is enable(tx_en=1), num of tx_pkts or rx_pkts have deviation,
 If wnat to calulate frame lost, session transmit must be disable(tx_en=0).
*/
struct ctc_npm_stats_s
{
    uint8 clear_en;               /**< [D2.TM.TMM.AT] if set, will clear cached stats after read.*/
    uint64 total_delay;          /**< [D2.TM.TMM.AT] total delay for test session, used to calculate average Frame Delay, uint:ns, for
                                 DMR/SLR/TWAMP means two-way total delay, for 1DM/OWAMP means one-way total delay*/
    uint64 total_near_delay;     /**< [D2.TM.TMM.AT] only used for DMR/SLR/TWAMP to calculate near direction delay, uint:ns */
    uint64 total_far_delay;      /**< [D2.TM.TMM.AT] only used for DMR/SLR/TWAMP to calculate far direction delay, uint:ns */
    uint64 first_ts;             /**< [D2.TM.TMM.AT] 1st receive packet timestamp, uint:ns */
    uint64 last_ts;              /**< [D2.TM.TMM.AT] last receive packet timestamp, uint:ns */

    uint64 tx_fcf;               /**< [D2.TM.TMM.AT] Tx fcf, used for SLR/1SL */
    uint64 tx_fcb;               /**< [D2.TM.TMM.AT] Tx fcb, used for SLR */
    uint64 rx_fcl;               /**< [D2.TM.TMM.AT] Rx fcl, used for SLR/1SL */

    uint64 tx_pkts;              /**< [D2.TM.TMM.AT] packet cnt stats in Tx Dir */
    uint64 rx_pkts;              /**< [D2.TM.TMM.AT] packet cnt stats in Rx Dir */
    uint64 tx_bytes;             /**< [D2.TM.TMM.AT] packet bytes stats in Tx Dir */
    uint64 rx_bytes;             /**< [D2.TM.TMM.AT] packet bytes stats in Rx Dir */
    uint8  tx_en;                /**< [D2.TM.TMM.AT] indicate autogen session transmit enable */
    uint64 max_delay;            /**< [TM.TMM.AT] max delay stats, uint:ns*/
    uint64 min_delay;            /**< [TM.TMM.AT] min delay stats, uint:ns*/
    uint32 max_jitter;           /**< [TM.TMM.AT] max jitter stats, it means two way max jitter for lite mode, uint:ns*/
    uint32 min_jitter;           /**< [TM.TMM.AT] min jitter stats, it means two way min jitter for lite mode, uint:ns*/
    uint64 total_jitter;         /**< [TM.TMM.AT] total jitter stats, it means two way total jitter for lite mode, uint:ns*/
    uint64 far_end_jitter[3];    /**< [TMM.AT] Far end max/min/total jitter stats, far_end_jitter[0] is max jitter, far_end_jitter[1] is min jitter and far_end_jitter[2] is total jitter, uint:ns*/
    uint64 near_end_jitter[3];   /**< [TMM.AT] Near end max/min/total jitter stats, near_end_jitter[0] is max jitter, near_end_jitter[1] is min jitter and near_end_jitter[2] is total jitter, uint:ns*/

    uint64 disorder_pkts;        /**< [TMM.AT] Rx packet cnt with wrong sequence for lite mode*/

    uint64 ir[2];                /**< [TMM.AT]  Rx IR(Information Rate) in 1s, rx_ir[0] is max ir and rx_ir[1] is min ir*/

    uint64 seconds;              /**< [TMM.AT] The time to calculate lost rate and IR*/
    uint64 ses_cnt[2];           /**< [TMM.AT] Total seconds in SES/non-SES state, ses_cnt[0] is seconds in SES state and ses_cnt[1] is seconds in non-SES state*/
    uint64 avl_periods[2];       /**< [TMM.AT] Total avaiable/unavaiable period seconds, avl_periods[0] is avaiable period seconds and avl_periods[1] is unavaiable period seconds*/
    uint8 in_avl_period;         /**< [TMM.AT] Meaning in available period now*/
};
typedef struct ctc_npm_stats_s ctc_npm_stats_t;

enum ctc_npm_session_mode_e
{
   CTC_NPM_SESSION_MODE_8 = 0,   /**<[D2.TM] Support max session number is 8, max header_len per session is 96bytes*/
   CTC_NPM_SESSION_MODE_6,       /**<[D2.TM] Support max session number is 6, max header_len per session is 128bytes*/
   CTC_NPM_SESSION_MODE_4,       /**<[D2.TM] Support max session number is 4, max header_len per session is 192bytes*/
   CTC_NPM_SESSION_MODE_32 = 0,  /**<[TMM.AT] Support max session number is 32, max header_len per session is 192bytes*/
   CTC_NPM_SESSION_MODE_16,      /**<[TMM.AT] Support max session number is 16, max header_len per session is 384bytes*/
};
typedef enum ctc_npm_session_mode_e ctc_npm_session_mode_t;

/*
 @brief   Define NPM global config parameter
*/
struct ctc_npm_global_cfg_s
{
    uint8 session_mode;                      /**< [D2.TM.TMM.AT] refer to ctc_npm_session_mode_t (default: CTC_NPM_SESSION_MODE_8)*/
    uint8 im_protocol;                       /**< [AT] protocol value of IP IM*/
    uint8 rsv[2];

    uint16 emix_size[CTC_NPM_MAX_EMIX_NUM];  /**< [D2.TM.TMM.AT] emix size array, can support max 16 frame size for emix mode (default: 0,0,0) */
};
typedef struct ctc_npm_global_cfg_s ctc_npm_global_cfg_t;


/*
 @brief   Define npm defect information entry
*/
struct ctc_npm_event_entry_s
{

    uint64    avl_periods[2];               /**< [TMM.AT] Total avaiable/unavaiable period seconds, avl_periods[0] is avaiable period seconds and avl_periods[1] is unavaiable period seconds*/
    uint64    ir[2];                        /**< [TMM.AT]  Rx IR(Information Rate) in 1s, rx_ir[0] is max ir and rx_ir[1] is min ir*/
    uint64    seconds;                      /**< [TMM.AT] The time to calculate lost rate and IR*/
    uint8     in_avl_period;                /**< [TMM.AT] Meaning in available period now*/
    uint32    session_id;                   /**< [TMM.AT] NPM session id*/
};
typedef struct ctc_npm_event_entry_s ctc_npm_event_entry_t;

/**
 @brief Define event data structure
*/
struct ctc_npm_event_s
{
    uint16 valid_num;                                               /**< [TMM.AT] Indicated valid event entry num */
    uint8  resv0[2];
    ctc_npm_event_entry_t event_entry[CTC_NPM_EVENT_MAX_NUM];       /**< [TMM.AT] Event entry ,refer to ctc_npm_event_entry_t */
};
typedef struct ctc_npm_event_s ctc_npm_event_t;

struct ctc_npm_im_loss_prof_s
{
    uint32 loss_prof_id;             /**< [TMM] loss prof id */
    uint32 interval;                 /**< [TMM] loss prof interval, unit:s */
};
typedef struct ctc_npm_im_loss_prof_s ctc_npm_im_loss_prof_t;

enum ctc_npm_im_flow_type_e
{
    CTC_NPM_IM_FLOW_TYPE_SOURCE,    /**< [TMM] source node */
    CTC_NPM_IM_FLOW_TYPE_TRANSIT,   /**< [TMM] transit node */
    CTC_NPM_IM_FLOW_TYPE_SINK,      /**< [TMM] sink node */
    CTC_NPM_IM_FLOW_TYPE_MAX
};
typedef enum ctc_npm_im_flow_type_e ctc_npm_im_flow_type_t;

enum ctc_npm_im_type_e
{
    CTC_NPM_IM_TYPE_MPLS,    /**< [TMM] MPLS IOAM */
    CTC_NPM_IM_TYPE_MAX
};
typedef enum ctc_npm_im_type_e ctc_npm_im_type_t;

struct ctc_npm_im_flow_s
{
    uint32 flow_id;               /**< [TMM] Flow id */
    uint8  type;                  /**< [TMM] IOAM with packet type, refer to ctc_npm_im_type_t*/
    uint8  flow_type;             /**< [TMM] Flow type, refer to ctc_npm_im_flow_type_t*/
    uint8  loss_prof_id;          /**< [TMM] Loss profile id, 0 is invalid, indicate loss measurement use which profile, only for source node */
    uint8  fih_type;              /**< [TMM] Only support 0x00, 0x01, 0x02 */
    uint32 stats_id;              /**< [TMM] Loss measurement statsid */
};
typedef struct ctc_npm_im_flow_s ctc_npm_im_flow_t;

enum ctc_npm_im_flow_property_type_e
{
    CTC_NPM_IM_FLOW_PROP_LOSS,               /**< [TMM] Loss measurement, set L bit value,  value: uint32*, TRUE or FALSE */
    CTC_NPM_IM_FLOW_PROP_DELAY,              /**< [TMM] Delay measurement, set D bit value,  value: uint32*, TRUE or FALSE */
    CTC_NPM_IM_FLOW_PROP_DELAY_INTERVAL,     /**< [TMM] Delay measurement invterval, only useful when hardware color mode enable, and 0 means disable hardware color, uint:1s */
    CTC_NPM_IM_FLOW_PROP_LOSS_INTERVAL,      /**< [TMM] Loss measurement interval, only useful when hardware color mode enable, and 0 means disable hardware color, uint:1s */
    CTC_NPM_IM_FLOW_PROP_MAX
};
typedef enum ctc_npm_im_flow_property_type_e  ctc_npm_im_flow_property_type_t;

struct ctc_npm_im_flow_property_s
{
    uint32 flow_id;             /**< [TMM] Flow id */
    uint32 property_type;       /**< [TMM] property type, refer to ctc_npm_im_flow_property_type_t */
    void *value;                /**< [TMM] property value, according to property type */
};
typedef struct ctc_npm_im_flow_property_s ctc_npm_im_flow_property_t;

/**
@brief Define event data structure
*/
struct ctc_npm_im_loss_s
{
    uint32 flow_id;                                /**< [TMM] Im Flow id*/
    uint8  loss_color;                             /**< [TMM] Loss color*/
    ctc_stats_basic_t stats[CTC_BOTH_DIRECTION];   /**< [TMM] flow id stats, include ingress and egress*/
};
typedef struct ctc_npm_im_loss_s ctc_npm_im_loss_t;

struct ctc_npm_im_event_s
{
    uint16 cnt;                              /**< [TMM] Report Im flow count */
    ctc_npm_im_loss_t  *loss_flow;           /**< [TMM] Refer to ctc_npm_im_loss_t */
};
typedef struct ctc_npm_im_event_s ctc_npm_im_event_t;

#ifdef __cplusplus
}
#endif

#endif

